package com.army.stock.service.impl;

import com.army.stock.dao.ArmySupplierDao;
import com.army.stock.domain.ArmySupplier;
import com.army.stock.service.ArmySupplierService;
import com.javalife.common.domain.page.PageInfo;
import com.javalife.common.domain.page.PaginatedArrayList;

import java.util.List;
import java.util.Map;

/**
 * Created by zhangyong on 14/12/26.
 * 军队供应商
 */
public class ArmySupplierServiceImpl implements ArmySupplierService {

    private ArmySupplierDao armySupplierDao;

    public void setArmySupplierDao(ArmySupplierDao armySupplierDao) {
        this.armySupplierDao = armySupplierDao;
    }

    public PaginatedArrayList getArmySupplierPageInfo(int currentPage, int pageSize, Map<String, Object> map) {
        int startNum = (currentPage - 1) * pageSize;
        map.put("start", startNum);
        map.put("pageSize", pageSize);
        Integer count = armySupplierDao.getCountArmySuppliers(map);
        List<ArmySupplier> suppliers = armySupplierDao.getArmySuppliers(map);
        PaginatedArrayList<ArmySupplier> paginatedArrayList = new PaginatedArrayList<ArmySupplier>(currentPage, pageSize);
        paginatedArrayList.setTotalItem(count);
        paginatedArrayList.addAll(suppliers);
        return paginatedArrayList;
    }

    public void insertArmySupplier(ArmySupplier armySupplier) {
        armySupplierDao.insertArmySupplier(armySupplier);
    }

    public ArmySupplier getArmySupplierById(Long id) {
        return armySupplierDao.getArmySupplierById(id);
    }

    public void updateArmySupplier(ArmySupplier armySupplier){
        armySupplierDao.updateArmySupplier(armySupplier);
    }

    public Integer delArmySupplier(Long id){
        return armySupplierDao.delArmySupplier(id);
    }

}
